﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using QunYing.BLL;

namespace Client
{
    public partial class FrmSelGoods : BasePopForm
    {
        public string str = "";
        public FrmSelGoods()
        {
            InitializeComponent();
        }

        private void FrmSelGoods_Load(object sender, EventArgs e)
        {
            QunYing.BLL.GoodsInfo goodsInfo = new GoodsInfo();
            DataTable dt = goodsInfo.GetList("是否下架=0  and 经销商编号='" + GlobalInfo.UserLoginInfo.用户ID + "' and 商品名称 like '%" + str + "%'").Tables[0];
            this.sharpGrid1.DataSource = dt;
            GridView view = this.sharpGrid1.MainView as GridView;
            view.Columns["商品ID"].Visible = false;
            view.Columns["经销商编号"].Visible = false;
            view.Columns["显示顺序"].Visible = false;
            view.Columns["类别ID"].Visible = false;
        }

        private void sharpGrid1_RowDoubleClickEvent(object sender, Spore.Controls.RowDoubleClickEventArg e)
        {
            SelectGoods();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSel_Click(object sender, EventArgs e)
        {
            SelectGoods();
        }

        private void SelectGoods()
        {
            GridView view = this.sharpGrid1.MainView as GridView;
            if (view.FocusedRowHandle>=0)
            {
                string strId=view.GetRowCellValue(view.FocusedRowHandle, "商品ID").ToString();
                string strName = view.GetRowCellValue(view.FocusedRowHandle, "商品名称").ToString();
                FrmAddActivity.frm.btnSel.Properties.Tag = strId;
                FrmAddActivity.frm.btnSel.Text = strName;
                this.Close();
            }
        }
    }
}